Skip to content

feat: LHCb modules migration#97

Draft
AcquaDiGiorgio wants to merge 15 commits intoDIRACGrid:mainfrom
AcquaDiGiorgio:issue-87-LHCb-UploadLogFile
Draft

feat: LHCb modules migration#97
AcquaDiGiorgio wants to merge 15 commits intoDIRACGrid:mainfrom
AcquaDiGiorgio:issue-87-LHCb-UploadLogFile

Conversation

@AcquaDiGiorgio
Copy link
Copy Markdown
Contributor

@AcquaDiGiorgio AcquaDiGiorgio commented Feb 4, 2026

See #87

First approach, needs review.

I tried to use the current Mock classes (MockDataManager), but I don't think this is the correct way. However, it should not vary much.

I open it as a draft because I still need to create 2 more tests and change the interactions with DIRAC.

@AcquaDiGiorgio AcquaDiGiorgio self-assigned this Feb 4, 2026
@AcquaDiGiorgio AcquaDiGiorgio linked an issue Feb 4, 2026 that may be closed by this pull request
4 tasks
@AcquaDiGiorgio
Copy link
Copy Markdown
Contributor Author

There is an issue with the FailoverRequest.
The DIRAC's workflow, during the finalize phase calls sendFailoverRequest, which through the ReqClient sends the stored requests at the workflow_commons dictionary to DIRAC.
Currently, in dirac-cwl we don't have persitency between command executions, so the operations created are lost.

@AcquaDiGiorgio AcquaDiGiorgio force-pushed the issue-87-LHCb-UploadLogFile branch from c3f5c70 to 93cb40c Compare February 16, 2026 11:34
@aldbr aldbr linked an issue Apr 15, 2026 that may be closed by this pull request
@AcquaDiGiorgio AcquaDiGiorgio changed the title feat: UploadLogFile command implementation feat: LHCb modules migration Apr 16, 2026
@AcquaDiGiorgio
Copy link
Copy Markdown
Contributor Author

This PR will now tackle the migration of every single module (starting from the ones used in MCSim) by importing LHCb specific functions instead of rewritting them from the ground up

"""Command classes for workflow pre/post-processing operations."""

from .analyze_xml_summary import AnalyseXmlSummary
from .bookkeeping_report import BookeepingReport
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, missing a k 🙂

Suggested change
from .bookkeeping_report import BookeepingReport
from .bookkeeping_report import BookkeepingReport


dsc = DataStoreClient()
dsc.addRegister(jobStep)
workflow_commons["accounting_registers"] = dsc.__registersList
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt this is going to work as registersList is a private attribute.
I guess you would need to add a public getRegisters() method within LHCbDIRAC no?

raise

finally:
save_workflow_commons(workflow_commons, workflow_commons_path, failed=failed)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for not declaring workflow_commons = {} before the try and keeping save_workflow_commons under the if workflow_commons here? You might get exception because workflow_commons won't be defined I think here. This looks correctly handled in upload_log_file for instance

Same issue in analyze_xml_summary and failover_request and upload_output_data

from dirac_cwl.core.exceptions import WorkflowProcessingException


def prepare_lhcb_workflow_commons(workflow_commons_path, extra_mandatory_values=[], extra_default_values={}):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's safer to have immutable default arguments:

Suggested change
def prepare_lhcb_workflow_commons(workflow_commons_path, extra_mandatory_values=[], extra_default_values={}):
def prepare_lhcb_workflow_commons(workflow_commons_path, extra_mandatory_values=None, extra_default_values=None):

Here you might have some surprises if you end up calling prepare_lhcb_workflow_commons multiple times in a row for any reason. (Just in case if you are not aware: https://florimond.dev/en/posts/2018/08/python-mutable-defaults-are-the-source-of-all-evil)

finally:
os.unlink(wf_backup)

return True
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the returned bool is never checked. Is that expected?


except Exception as e:
failed = True
raise WorkflowProcessingException() from e
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No message here?

jobStep.setStartTime(now)
jobStep.setEndTime(now)

dataDict = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also needs to be typed

"mcTCK": None,
"condDB_tag": None,
"DQ_tag": None,
"step_status": S_OK(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

step_status is either Done or Failed, not S_OK/S_ERROR. Check within the StepAccounting module in LHCbDIRAC

Suggested change
"step_status": S_OK(),
"step_status": "Done",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point that should just be a boolean but we cannot change it for now (though you can add a comment for later)

"inputs",
"outputs", # outputList
"executable",
"command_id", # StepID
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure to understand why this is renamed command_id 😅

from .utils import prepare_lhcb_workflow_commons, save_workflow_commons


class FailoverRequest(PostProcessCommand):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you are not setting the application status, is that expected? (this can be done through diracX)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrate real LHCb workflow commands (Pre/PostExecution) LHCb Workflow: UploadLogFile command

2 participants